package com.sxu.demo.aqs;

public class TestAQS {
    public static void main(String[] args) {
        MyLock lock = new MyLock();
        new Thread(()->{
            lock.lock();
            try {
                System.out.println("t1 locking...");
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            } finally {
                System.out.println("t1 unlocking...");
                lock.unlock();
            }
        },"t1").start();

        new Thread(()->{
            lock.lock();
            try {
                System.out.println("t2 locking...");
            } finally {
                System.out.println("t2 unlocking...");
                lock.unlock();
            }
        },"t2").start();
    }
}
